package leecode0_1;

public class arraySign {
    public static void main(String[] args) {

       // 1,2,2,2,6,4,0,0
        int arr[] = new int[]{0,2,3,4,0};
        //sign                2 3 4 0 0
        //
        int begin=0,end=0;

        int temp;
        //双指针，左指针指向当前已经处理好的序列的尾部，右指针指向待处理序列的头部。
        while (end<arr.length){
            if (arr[end]!=0){
                temp = arr[begin];
                arr[begin] = arr[end];
                arr[end] = temp;
                begin++;
            }
            end++;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }

    }
}
